#set( $symbol_pound = '#' )
#set( $symbol_dollar = '$' )
#set( $symbol_escape = '\' )
package ${groupId};

import java.util.ServiceLoader;

import lombok.SneakyThrows;
import lombok.extern.log4j.Log4j;

import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;

import com.google.guiceberry.GuiceBerryEnvMain;
import com.google.guiceberry.GuiceBerryModule;
import com.google.inject.Module;
import com.google.inject.Provides;

@Log4j
public class AppGuiceBerryEnv extends GuiceBerryModule {

	@Provides
	@SneakyThrows
	HelloService createUserService() {
		Service serviceModel = new ObjectServiceFactory()
				.create(HelloService.class);
		HelloService service = (HelloService) new XFireProxyFactory().create(
				serviceModel, "http://localhost:9999/services/HelloService");
		return service;
	}

	@Override
	protected void configure() {
		super.configure();
		bind(GuiceBerryEnvMain.class).to(JettyServerStarter.class);

		for (Module module : ServiceLoader.load(Module.class)) {
			log.info("loading module: " + module.getClass().getCanonicalName());
			install(module);
		}

	}

}
